package singleton;

/**
 * @ClassName : innerClassSingleton
 * @Description : 内部类单例模式
 * @Author : gyh
 * @Date: 2021-09-05 01:42
 */
class InnerClassSingleton {

    private InnerClassSingleton() {
    }

    private static class InnerClass {
        private final static InnerClassSingleton instance = new InnerClassSingleton();
    }

    public static InnerClassSingleton getInstance() {
        return InnerClass.instance;
    }


    public static void main(String[] args) {
        for (int i = 0; i < 100; i++) {
            new Thread(()->{
                System.out.println(InnerClassSingleton.getInstance().hashCode());
            }).start();
        }
    }
}
